const path = require("path")
const apiMocker = require("mocker-api")

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  chainWebpack: (config) => {
    config.resolve.alias.set("@", resolve("src"))
  },
  devServer: {
    // 期望使用mock接口,则将请求以 /api/xxx 开头
    before(app) {
      apiMocker(app, path.resolve("./mock/index.js"), {
        proxy: {},
        changeHost: true
      })
    }
  }
}
